using System;
using System.Collections;
using System.Collections.Generic;
using Me.Prettyprint.Cassandra.Connection;
using Me.Prettyprint.Cassandra.Service;
using Me.Prettyprint.Hector.Api;
using Me.Prettyprint.Hector.Api.Query;

namespace Me.Prettyprint.Cassandra.Model
{
    /// <summary>
    /// Other query classes extend AbstractBasicQuery. Nectar uses the same fluent approach
    /// to API design as Hector.
    /// </summary>
    /// <typeparam name="K"></typeparam>
    /// <typeparam name="N"></typeparam>
    /// <typeparam name="T"></typeparam>
	public abstract class AbstractBasicQuery<K, N, T> : Query<T>
	{
        protected AbstractBasicQuery(Keyspace k, Serializer<K> keySerializer,
            Serializer<N> nameSerializer)
        {
            if (k == null || keySerializer == null || nameSerializer == null)
            {
                throw new NullReferenceException("keyspace, key serializer and name serializer cannot be null");
            }
            Keyspace = (ExecutingKeyspace)k;
            KeySerializer = keySerializer;
            ColumnNameSerializer = nameSerializer;
        }
        public string ColumnFamilyName
        {
            get;
            set;
        }
        public string CqlVersion
        {
            get;
            set;
        }
        public Serializer<K> KeySerializer
        {
            get;
            set;
        }
        public Serializer<N> ColumnNameSerializer
        {
            get;
            set;
        }
        public ExecutingKeyspace Keyspace
        {
            get;
            private set;
        }
        public HConsistencyLevel ConsistencyLevel
        {
            get;
            set;
        }
        public virtual Query<T> SetColumnFamily(string cf)
        {
            ColumnFamilyName = cf;
            return this;
        }
        public abstract QueryResult<T> Execute();
    }
}